'use strict';

/**
 * @name TechDetailEditCtrl
 * @author ZYF
 */

angular.module('metalabOperationApp').controller('TechDetailEditCtrl', ['$scope', '$rootScope', '$state', '$stateParams', 'MetaResources', 'MetaRemind', 'MetaEdit', function($scope, $rootScope, $state, $stateParams, MetaResources, MetaRemind, MetaEdit) {
    $scope.editCtrl = {
        data: {}
    };
    $scope.init = function() {
        MetaEdit.initEditModule($scope, $stateParams, 'technology', 'publisher,leader,projectManager,other,verifier');
    };
    $scope.save = function() {
        MetaEdit.setPreProcess($scope.editCtrl.data, 'technology');
        //更新技术信息
        MetaResources.technology.save({
                'id': $stateParams.id,
                '_embed': 'publisher,leader,projectManager'
            }, $scope.editCtrl.data,
            function() {
                MetaRemind.success("恭喜", "修改成功");
                MetaEdit.syncData($scope.editCtrl, 'technology');
            },
            function(error) {
                MetaRemind.serverError(error);
            });
    };

    $scope.toBeContinued = MetaRemind.error;
    $scope.init();
}]);
